package com.fy.distributor.controller;

import com.fy.common.api.CommonResult;
import com.fy.common.util.BeansUtil;
import com.fy.distributor.vo.*;
import com.fy.shop.api.DistributorService;
import com.fy.shop.dto.IsShowProductDto;
import com.fy.shop.dto.UpPlatformDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/distributor/product")
@Api(tags="分销商商品操作模块")
@RefreshScope
public class ProductController {

    @Autowired
    private DistributorService distributorService;

    @ApiOperation("添加商品到门店")
    @PostMapping(value = "/addProduct")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id"),
            @ApiImplicitParam(name = "type", value = "类型（门票 ，实物）"),
            @ApiImplicitParam(name = "storeId", value = "门店id")
    })
    public List<UpPlatformVo> addProduct(@RequestBody IsShowProductVo isShowProductVo) {
        IsShowProductDto isShowProductDto = new IsShowProductDto();
        BeanUtils.copyProperties(isShowProductVo,isShowProductDto);
        List<UpPlatformDto> upPlatformDtoList = distributorService.addProduct(isShowProductDto);
        List<UpPlatformVo> upPlatformVos = BeansUtil.listCopy(upPlatformDtoList,UpPlatformVo.class);
        return upPlatformVos;
    }

    @ApiOperation("从门店中移除商品")
    @PostMapping(value = "/removeProduct")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id"),
            @ApiImplicitParam(name = "type", value = "类型（门票 ，实物）"),
            @ApiImplicitParam(name = "storeId", value = "门店id")
    })
    public List<UpPlatformVo> removeProduct(@RequestBody IsShowProductVo isShowProductVo) {
        IsShowProductDto isShowProductDto = new IsShowProductDto();
        BeanUtils.copyProperties(isShowProductVo,isShowProductDto);
        List<UpPlatformDto> upPlatformDtoList = distributorService.removeProduct(isShowProductDto);
        List<UpPlatformVo> upPlatformVos = BeansUtil.listCopy(upPlatformDtoList,UpPlatformVo.class);
        return upPlatformVos;
    }

    @ApiOperation("是否上架产品")
    @PostMapping(value = "/isShowProduct")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id"),
            @ApiImplicitParam(name = "storeId", value = "门店id"),
            @ApiImplicitParam(name = "type",value = "产品类型")
    })
    public CommonResult isShowProduct(@RequestBody IsShowProductVo isShowProductVo){
        IsShowProductDto isShowProductDto  = new IsShowProductDto();
        BeanUtils.copyProperties(isShowProductVo,isShowProductDto);
        distributorService.isShowProduct(isShowProductDto);
        return CommonResult.success(null);
    }


    @ApiOperation("查询平台所有门票")
    @GetMapping(value = "/findTicketAll")
    @ApiImplicitParam(name = "type", value = "类型")
    public CommonResult findTicketAll(Integer type)
    {
        List<TicketVo> ticketVoList = null;
        return CommonResult.success(ticketVoList);
    }

    @ApiOperation("查询平台所有实物")
    @GetMapping(value = "/findSpecialtyAll")
    @ApiImplicitParam(name = "type", value = "类型")
    public CommonResult findSpecialtyAll(Integer type)
    {
        List<ProductVo> productVoList = null;
        return CommonResult.success(productVoList);
    }

    @ApiOperation("搜索平台所有商品")
    @GetMapping(value = "/search")
    @ApiImplicitParam(name = "name", value = "输入的产品名")
    public CommonResult search(String name)
    {
        UpPlatformVo upPlatformVo = null;
        return CommonResult.success(upPlatformVo);
    }


    @ApiOperation("查询店铺上架所有门票")
    @GetMapping(value = "/findAddTicketAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "storeId", value = "门店id"),
            @ApiImplicitParam(name = "type", value = "类型")
    })
    public CommonResult findAddTicketAll(Integer storeId,Integer ticketId)
    {
        List<TicketVo> ticketVoList = null;
        return CommonResult.success(ticketVoList);
    }

    @ApiOperation("查询店铺上架所有实物")
    @GetMapping(value = "/findAddSpecialtyAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "storeId", value = "门店id"),
            @ApiImplicitParam(name = "type", value = "类型")
    })
    public CommonResult findAddSpecialtyAll(Integer storeId, Integer productId)
    {
        List<ProductVo> productVoList = null;
        return CommonResult.success(productVoList);
    }

    @ApiOperation("搜索店铺上架所有商品")
    @GetMapping(value = "/shopSearch")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "输入的产品名"),
            @ApiImplicitParam(name = "storeId", value = "门店id")
    })
    public CommonResult shopSearch(String name, Integer storeId)
    {
        UpPlatformVo upPlatformVo = null;
        return CommonResult.success(upPlatformVo);
    }

    @ApiOperation("查看商品详情")
    @GetMapping(value = "/findByProductId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "点击的产品id"),
            @ApiImplicitParam(name = "type", value = "类型（门票 ，实物）"),
            @ApiImplicitParam(name = "storeId", value = "门店id")
    })
    public CommonResult findByProductId(Integer id, Integer type,Integer storeId)
    {
        UpPlatformVo upPlatformVo = null;
        return CommonResult.success(upPlatformVo);
    }

    @ApiOperation("查询门票价格日历")
    @GetMapping(value = "/calendarFindByTicketId")
    @ApiImplicitParam(name = "ticketId", value = "门票id")
    public CommonResult calendarFindByTicketId(Integer ticketId)
    {
        List<CalendarVo> calendarVoList = null;
        return CommonResult.success(calendarVoList);
    }
}
